package com.yc.vcode;

import com.yc.vcode.bean.VcodeProperties;
import com.yc.vcode.web.VcodeInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Company 源辰信息
 *
 * @author navy
 * @date 2024/8/19
 * Email haijunzhou@hnit.edu.cn
 */
@AutoConfiguration
@ComponentScan("com.yc.vcode")
@ConditionalOnProperty(prefix = "vcode",name = "enable",havingValue = "true")
@Slf4j
public class VcodeConfig implements WebMvcConfigurer {

    @Autowired
    VcodeProperties properties;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new VcodeInterceptor())
                .addPathPatterns(properties.getPaths());
    }
}
